package com.ncd.disease.controller;

import java.util.List;

import com.ncd.common.core.text.Convert;
import com.ncd.common.utils.ServletUtils;
import com.ncd.disease.param.RetAdmParam;
import com.ncd.disease.result.RetAdmResult;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.*;
import com.ncd.common.annotation.Log;
import com.ncd.common.enums.BusinessType;
import com.ncd.disease.domain.RetAdm;
import com.ncd.disease.service.IRetAdmService;
import com.ncd.common.core.controller.BaseController;
import com.ncd.common.core.domain.AjaxResult;
import com.ncd.common.utils.poi.ExcelUtil;
import com.ncd.common.core.page.TableDataInfo;

/**
 * 复诊Controller
 * 
 * @author zhouxin
 * @date 2024-03-10
 */
@Controller
@RequestMapping("/disease/adm")
public class RetAdmController extends BaseController
{
    private String prefix = "disease/adm";

    @Autowired
    private IRetAdmService retAdmService;

    @RequiresPermissions("disease:adm:view")
    @GetMapping()
    public String adm(ModelMap mmap)
    {
        mmap.put("dia", ServletUtils.getParameter("dia"));
        mmap.put("admType", ServletUtils.getParameter("admType"));
        return prefix + "/adm";
    }

    /**
     * 查询复诊列表
     */
    @RequiresPermissions("disease:adm:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(RetAdm retAdm)
    {
        startPage();
        List<RetAdmResult> list = retAdmService.selectRetAdmList(retAdm);
        return getDataTable(list);
    }

    /**
     * 导出复诊列表
     */
    @RequiresPermissions("disease:adm:export")
    @Log(title = "复诊", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(RetAdm retAdm)
    {
        List<RetAdmResult> list = retAdmService.selectRetAdmList(retAdm);
        ExcelUtil<RetAdmResult> util = new ExcelUtil<RetAdmResult>(RetAdmResult.class);
        return util.exportExcel(list, "复诊数据");
    }


    /**
     * 新增保存复诊
     */
    @RequiresPermissions("disease:adm:add")
    @Log(title = "复诊", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(@RequestBody RetAdm retAdm)
    {
        return toAjax(retAdmService.insertRetAdm(retAdm));
    }


    /**
     * 修改保存复诊
     */
    @RequiresPermissions("disease:adm:edit")
    @Log(title = "复诊", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(@RequestBody RetAdmParam retAdmParam)
    {
        return toAjax(retAdmService.updateRetAdm(retAdmParam));
    }

    /**
     * 删除复诊
     */
    @RequiresPermissions("disease:adm:remove")
    @Log(title = "复诊", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(retAdmService.removeByIds(Convert.toLongList(ids)));
    }
}
